package cn.wdm.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration //表示当前类为配置类 相当于spring-mvc.xml核心配置文件
public class WebConfigurer implements WebMvcConfigurer {

    /**
     *配置拦截器 注入需要配置的拦截器 然后将配置类配置到spring的拦截器链中 拦截器才能生效
     * @param registry
     */
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)//添加拦截器
                .addPathPatterns("/**")//拦截所有请求 拦截

                .excludePathPatterns("/login/**")//登录下的所有放行 放行
                .excludePathPatterns("/shop/settlement")
                .excludePathPatterns("/user/register/**")
                .excludePathPatterns("/fastDfs/**")
                .excludePathPatterns("/verifyCode/**");
    }
}
